Release 10.1A: OpenEdge Development:
Web Services
Managing asynchronous requests
As indicated previously, you can invoke Web service requests asynchronously from the 4GL. This means that you can invoke a Web service request in such a way that the result is handled independently of the mainline flow of execution. That is, 4GL statements following the asynchronous request execute immediately and in order without waiting for the result of the asynchronous request to be available. Instead, the asynchronous request specifies an internal event procedure to handle the result when the result for that asynchronous request becomes available, which is signalled by the activation of a
PROCEDURE-COMPLETEevent.When it is time to handle the
PROCEDURE-COMPLETEevent, the specified event procedure executes and manages anyOUTPUTorINPUT-OUTPUTparameters that were passed to the asynchronous request when it was invoked. These parameters are returned asINPUTparameters to the event procedure, which can store the parameter values or otherwise process the result for use by the mainline program. The mainline program can periodically inspect an asynchronous request object handle (also available to the event procedure), which it sets during invocation of the request, in order to determine if the specified asynchronous request has completed. If the request has completed, the program can then make use of the results as provided by the internal event procedure that handled them.The model for asynchronous Web service request invocation is very similar to the model for asynchronous remote procedure invocation on a session-free AppServer. This section describes the asynchronous Web service calling model, noting any differences from the asynchronous session-free AppServer calling model. For information on the model for invoking asynchronous requests on a session-free AppServer, see OpenEdge Application Server: Developing AppServer Applications .
Note: For certain features that support Web service requests in the 4GL (for example, error handling), the feature behavior might differ depending on whether the request is synchronous or asynchronous. The documentation describes these differences in the chapters where the features are described.Supported asynchronous Web service requests
You can only invoke an asynchronous Web service request as a procedure using the
RUNstatement. This means that if a Web service operation is invoked as a user-defined function, you can only invoke it synchronously, because all operations that have a return value can only be invoked as user-defined functions, where the value must be made available at the point of invocation. This is consistent with how OpenEdge supports the invocation of asynchronous requests on the AppServer (remote procedures only).Order of completion
Similar to a session-free AppServer request, the order of completion for an asynchronous Web service request is determined solely by the Web service. The manner in which the 4GL client send and response queues for an asynchronous request handle messages is identical for both session-free asynchronous AppServer requests and asynchronous Web service requests. That is, if the 4GL invokes multiple asynchronous Web service requests, the order of their completion cannot be determined on the Web service or session-free AppServer client. So, you must write your mainline program, and indeed your asynchronous event procedures, to make no assumptions about the order in which multiple asynchronous Web service requests complete.
A subtle distinction between a session-free asynchronous AppServer request and an asynchronous Web service request is the SOAP response callback procedure available for the Web service request (see the "Handling the information in SOAP headers" section). If a SOAP response callback procedure is set for an asynchronous Web service request, it executes after the SOAP response message arrives at the client but before the asynchronous event procedure executes to handle the
PROCEDURE-COMPLETEevent for the request.Asynchronous request object handle
OpenEdge maintains an asynchronous request object for each asynchronous request, which maintains the status of the request, including whether and how it has completed (successfully or unsuccessfully). The handle to this asynchronous request object is available to the mainline program and to the event procedure for an asynchronous Web service request in the same way as for an asynchronous AppServer request. The Web service server object handle maintains its own chain of pending asynchronous request object handles (
FIRST-ASYNC-REQUESTandLAST-ASYNC-REQUESTattributes), and thePROCEDURE-NAMEattribute on each asynchronous request object handle returns the name of its Web service operation as it returns the name of the remote procedure executed for an asynchronous AppServer request.Table 1–3 shows attributes on the asynchronous object handle with special meaning for Web services.
Results handling
A few differences exist in the results returned for an asynchronous Web service request compared to an asynchronous AppServer request, as shown in Table 1–4.
Table 1–4: Results for asynchronous Web service requests 4GL result elements Web service request resultERROR-STATUSsystem handle If theERRORattribute of the asynchronous request object handle is set toTRUEbecause of a SOAP fault, theERROR-STATUS:ERROR-OBJECT-DETAILattribute references a SOAP fault object with information on the SOAP fault (see the "Handling Web service errors" section).RETURN-VALUEfunction The value for 4GLRETURN-VALUEfunction is never altered directly by the response from a Web service asynchronous request.STOPcondition The client can raise theSTOPcondition by executing theCANCEL-REQUESTS( )method on the Web service server object handle. All outstanding Web service requests are handled in a similar manner to those on an AppServer, except that for any currently executing Web service requests, the result is undefined. OpenEdge disconnects from all ports to currently executing Web service requests, and the exact response depends on how the Web service responds to the lost connection.
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |